<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My Web Application</title>
<meta  name="viewport" content="width=divice-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" />
<link rel="stylesheet" type="text/css" href="../themes/Theme_app.css">
<link rel="stylesheet" type="text/css" href="../themes/jquery.mobile.icons.min.css">
<link rel="stylesheet" type="text/css" href="../themes/Theme_app.min.css">
<link rel="stylesheet" type="text/css" href="../css/Css_Header.css">
<link rel="stylesheet" type="text/css" href="../css/table.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

<style>

</style>

</head>
<body>
<div data-role="page" id="page">
  <div data-role="header">
    <h1>My Web Application</h1>
  </div>
  <div >
     <img src="../images/banner.jpg" width="1500" height="100"> 
  </div>
  <div align="center">
     เว็บแอพพพลิเคชั่นเตรียมพร้อมสอบใบขับขี่รถยนต์ส่วนบุคคล
  </div>
  <div data-role="content">
        <div data-role="content">
            <ul data-role="listview">       
                <input type="button" id="page4" value="หมวด กฎหมายว่าด้วยรถยนต์" >
            </ul>
       </div>  
       <form name="form1" method="post" >
<?
include('../connect/connect.php');
$sql="Select * From Question_2 order by rand() limit 5";
$db_query=mysql_query($sql);
$i=0;
while($result=mysql_fetch_array($db_query))
{
$i++;
?>
<table width="90%" border="0" align="center">
  <tr>
    <td colspan="3">
    <input name="id<?=$i;?>" type="hidden" value="<?=$result["id"];?>">
    <?php echo"$i";  ?> :<?=$result["question"];?>
   </td> 
 </tr>
 <tr >
    <div class="css-checkbox"><td width="5px"  ><input name="c<?=$i;?>" type="radio"  value="1" ></td></div>
    <td width="95px" colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$result["c1"];?></td>
</tr> 
 <tr>
    <td width="5px" ><input type="radio" name="c<?=$i;?>" value="2"></td>
    <td width="95px" colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$result["c2"];?></td>
</tr> 
 <tr>
    <td width="5px" ><input type="radio" name="c<?=$i;?>" value="3"></td>
    <td width="95px" colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$result["c3"];?></td>
</tr> 
 <tr>
    <td width="5px" ><input type="radio" name="c<?=$i;?>" value="4"></td>
    <td width="95px" colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$result["c4"];?></td>
    <td ><input name="answer<?=$i;?>" type="hidden" value="<?=$result["answer"];?>"></td>
</tr> 
</table>
<?
}
mysql_close();
?>
<div align="center"><br>
<input type="hidden" name="line" value="<?=$i;?>">

<input type="submit" name="Submit" value="ตรวจคะแนน" >
<a href="#myPopupDialog" data-rel="popup" data-position-to="window" data-transition="fade" class="ui-btn ui-corner-all ui-shadow ui-btn-inline">ตรวจคะแนน</a>
</div>
<?
$score=0;
for($i=1;$i<=$_POST["line"];$i++)
{
	if($_POST["c$i"] == $_POST["answer$i"])
	{
			$score=$score+1;
	}
}
if($score=="")
{
	}
else if($score<4)
{
	echo"คะแนนเต็ม 5 ตะแนน";
	echo"คะแนนที่คุณได้ $score คะแนน ไม่ผ่านการทดสอบ";
}else{
	echo"คะแนนเต็ม 5 ตะแนน";
	echo"คะแนนที่คุณได้ $score คะแนน ยินดีด้วยคุณผ่านการทดสอบ";
}

?>

</div>

       <div data-role="popup" id="myPopupDialog">
              <div data-role="header">
                <h1>ผลการตรวจคะแนนข้อสอบ</h1>
              </div>
              <?php include'Sample2.php' ?>
              <div data-role="main" class="ui-content">
                <h2>คะแนนที่ท่านทำได้</h2>
                <p>
                
                </p>
                <a href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b ui-icon-back ui-btn-icon-left" data-rel="back">Go Back</a>
              </div>
        
              <div data-role="footer">
                <h1>Footer Text</h1>
              </div>
        </div>
</form>           
   <a href="../page4.php" class="ui-btn ui-icon-back ui-btn-icon-left" data-transition="slide" data-direction="reverse">กลับหน้าเมนูข้อสอบทฤษฏี</a>  
  <div data-role="footer">
    <h4>@Computer Science</h4>
  </div>
</div>
</body>
</html>


